package com.kaishengit.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import com.kaishengit.pojo.News;
import com.kaishengit.pojo.Project;
import com.kaishengit.pojo.User;
import com.kaishengit.util.CreateTime;
import com.kaishengit.util.MyUUID;
import com.kaishengit.util.Outtime;

@Service
@Transactional
public class NewsService extends BaseService {
	
	public List<News> getNewss(Project project) {
		return getNewsDao().findByProject(project);
		
	}

	public void save(News news, Project project, User user) {
		
		news.setId(MyUUID.createUUID().toString());
		news.setCreatetime(CreateTime.createTime());
		news.setProject(project);
		news.setUser(user);
		
		getNewsDao().save(news);
		
	}
	
	public List<News> getnewstime(Project project) {
		List<News> news = getNewsDao().findByProject(project);
		for (int i = 0; i < news.size(); i++) {
			news.get(i).setOuttime(
					Outtime.OutDateTime(news.get(i).getCreatetime()));
		}
		return news;

	}
}
